package demo;


class Student{
    private String name;
    private int age;
    //private  static String classRoom = "115java" ;
    private  static String classRoom  ;



    //非静态代码块（实例代码块）
    {
        System.out.println("实例代码块执行了  1.......");
    }
    {
        System.out.println("实例代码块执行了  2.......");
    }


    //静态代码块
    static {
        classRoom = "115java";
        System.out.println("静态代码块执行了  1.......");
    }
    static {
        System.out.println("静态代码块执行了  2.......");
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("构造public Student(String name, int age)方法执行了......");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public static String getClassRoom() {
        return classRoom;
    }

    public static void setClassRoom(String classRoom) {
        Student.classRoom = classRoom;
    }


//    public String toString() {
//        return "姓名："+name+" 年龄："+age + " 上课教室："+classRoom;
//    }


    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}



public class TestDemo {

    public static void main(String[] args) {
        Student student1 = new Student("Wangjunkai",25);
        System.out.println(student1);
    }



    public static void main2(String[] args) {
        System.out.println(Student.getClassRoom());
    }


    public static void main1(String[] args) {
        Student student1 = new Student("Karry",25);

        System.out.println("============");

        Student student2 = new Student("Jun",19);
    }
}
